import 'dart:ui';

import 'base/base_effect.dart';
import 'effect_template.dart';

class Effect02 extends EditableAnimationEffect {
  @override
  List<Color> get defaultColors {
    return const [
      Color(0xFFFF0000),
      Color(0xFFFF00FF),
      Color(0xFF9000FF),
      Color(0xFF0000FF),
      Color(0xFF00FFFF),
      Color(0xFF00FF00),
      Color(0xFFFFFF00),
      Color(0xFFFF8200),
    ];
  }

  @override
  bool get enableAngle => true;

  @override
  RangeArgument get angleRange => RangeArgument(-180, 180, 0);

  @override
  bool get enableColorWidth => true;

  @override
  RangeArgument get colorWidthRange => RangeArgument(2, 6, 3);

  @override
  bool get enableDensity => true;

  @override
  RangeArgument get densityRange => RangeArgument(1, 10, 5);

  @override
  bool get enableEditColor => true;

  @override
  bool get enableSpeed => true;

  @override
  RangeArgument get speedRange => RangeArgument(0, 9, 7);

  @override
  bool get isFixedColorCount => false;

  @override
  RangeArgument get colorCountRange => RangeArgument(1, 7, 5);

  @override
  EffectType get effectTyp => EffectType.effect02;

  @override
  Future<List<List<List<Color>>>> getFrames({EffectOperation? operation}) {
    List<Color> colorList = getColorList(effectOperation: operation);
    List<List<List<Color>>> frames = [];
    final length = colorList.length;
    for (int z = 0; z < colorList.length; z++) {
      List<List<Color>> columns = [];
      for (int i = 0; i < size.width; i++) {
        List<Color> rows = [];
        for (int j = 0; j < size.height; j++) {
          final index = (length - (z + (colorList.length - i) + j)) % length;
          final color = colorList[index];
          rows.add(color);
        }
        columns.add(rows);
      }
      frames.add(columns);
    }
    return Future.value(frames);
  }

  @override
  Size get size => const Size(24, 24);
}